package fr.afcepf.qualimetrie.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * The persistent class for the stagiaire database table.
 */
@Entity
@NamedQueries({
        @NamedQuery(name = "Stagiaire.findAll", query = "SELECT s FROM Stagiaire s"),
        @NamedQuery(name = "Stagiaire.findByName", query = "SELECT s FROM Stagiaire s WHERE s.nom = :name"),
        @NamedQuery(name = "Stagiaire.findByOrganismeId", query = "SELECT s FROM Stagiaire s WHERE s.organisme.id = :organismeId") })
public class Stagiaire implements Serializable {
    /**
     * serial.
     */
    private static final long serialVersionUID = 1L;
    /**
     * namedQuery.
     */
    public static final String FIND_ALL = "Stagiaire.findAll";
    /**
     * namedQuery.
     */
    public static final String FIND_BY_NAME = "Stagiaire.findByName";
    /**
     * namedQuery.
     */
    public static final String FIND_BY_ORGANISME_ID = "Stagiaire.findByOrganismeId";

    /**
     * id.
     */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private int id;
    /**
     * adresse.
     */
    private String adresse;
    /**
     * date.
     */
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "date_naissance")
    private Date dateNaissance;
    /**
     * nom.
     */
    private String nom;
    /**
     * prenom.
     */
    private String prenom;
    /**
     * organisme.
     */
    // bi-directional many-to-one association to Organisme
    @ManyToOne()
    @JoinColumn(name = "id_organisme")
    private Organisme organisme;

    /**
     * Constructeur.
     */
    public Stagiaire() {
    }

    /**
     * @return the id
     */
    public int getId() {
        return id;
    }

    /**
     * @param paramId the id to set
     */
    public void setId(int paramId) {
        id = paramId;
    }

    /**
     * @return the adresse
     */
    public String getAdresse() {
        return adresse;
    }

    /**
     * @param paramAdresse the adresse to set
     */
    public void setAdresse(String paramAdresse) {
        adresse = paramAdresse;
    }

    /**
     * @return the dateNaissance
     */
    public Date getDateNaissance() {
        return dateNaissance;
    }

    /**
     * @param paramDateNaissance the dateNaissance to set
     */
    public void setDateNaissance(Date paramDateNaissance) {
        dateNaissance = paramDateNaissance;
    }

    /**
     * @return the nom
     */
    public String getNom() {
        return nom;
    }

    /**
     * @param paramNom the nom to set
     */
    public void setNom(String paramNom) {
        nom = paramNom;
    }

    /**
     * @return the prenom
     */
    public String getPrenom() {
        return prenom;
    }

    /**
     * @param paramPrenom the prenom to set
     */
    public void setPrenom(String paramPrenom) {
        prenom = paramPrenom;
    }

    /**
     * @return the organisme
     */
    public Organisme getOrganisme() {
        return organisme;
    }

    /**
     * @param paramOrganisme the organisme to set
     */
    public void setOrganisme(Organisme paramOrganisme) {
        organisme = paramOrganisme;
    }

    /*
     * (non-Javadoc)
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;

        result = prime * result;
        if ((adresse != null)) {
            result += adresse.hashCode();
        }

        result = prime * result;
        if ((dateNaissance != null)) {
            result += dateNaissance.hashCode();
        }

        result = prime * result;
        if ((nom != null)) {
            result += nom.hashCode();
        }

        result = prime * result;
        if ((prenom != null)) {
            result += prenom.hashCode();
        }

        return result;
    }

    /*
     * (non-Javadoc)
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        Stagiaire other = (Stagiaire) obj;
        if (adresse == null) {
            if (other.adresse != null) {
                return false;
            }
        } else if (!adresse.equals(other.adresse)) {
            return false;
        }
        if (dateNaissance == null) {
            if (other.dateNaissance != null) {
                return false;
            }
        } else if (!dateNaissance.equals(other.dateNaissance)) {
            return false;
        }
        if (nom == null) {
            if (other.nom != null) {
                return false;
            }
        } else if (!nom.equals(other.nom)) {
            return false;
        }
        if (prenom == null) {
            if (other.prenom != null) {
                return false;
            }
        } else if (!prenom.equals(other.prenom)) {
            return false;
        }
        return true;
    }

}
